package com.example.finalwork.Pay;

import android.content.Intent;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.finalwork.MainActivity;
import com.example.finalwork.R;

public class PayMainActivity extends AppCompatActivity implements View.OnClickListener {
    private TextView pay_add,pay_update,pay_del,pay_getall,pay_exit;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay);
        pay_add = findViewById(R.id.pay_add);
        pay_update = findViewById(R.id.pay_update);
        pay_del = findViewById(R.id.pay_del);
        pay_getall = findViewById(R.id.pay_getall);
        pay_exit = findViewById(R.id.pay_exit);

        findViewById(R.id.pay_add).setOnClickListener(this);
        findViewById(R.id.pay_del).setOnClickListener(this);
        findViewById(R.id.pay_update).setOnClickListener(this);
        findViewById(R.id.pay_getall).setOnClickListener(this);
        findViewById(R.id.pay_exit).setOnClickListener(this);

        //Intent intent = getIntent();
        //tring data = intent.getStringExtra("UserName");
        //Toast.makeText(this,MainActivity.data,Toast.LENGTH_SHORT).show();

        Drawable dwpay_add = getResources().getDrawable(R.drawable.incomeadd);
        dwpay_add.setBounds(0, 0, 100, 100);
        pay_add.setCompoundDrawables(dwpay_add, null, null, null);
        pay_add.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        pay_add.getPaint().setAntiAlias(true);//抗锯齿

        Drawable dwpay_update = getResources().getDrawable(R.drawable.incomeupdate);
        dwpay_update.setBounds(0, 0, 100, 100);
        pay_update.setCompoundDrawables(dwpay_update, null, null, null);
        pay_update.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        pay_update.getPaint().setAntiAlias(true);//抗锯齿

        Drawable dwpay_del = getResources().getDrawable(R.drawable.incomedel);
        dwpay_del.setBounds(0, 0, 100, 100);
        pay_del.setCompoundDrawables(dwpay_del, null, null, null);
        pay_del.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        pay_del.getPaint().setAntiAlias(true);//抗锯齿

        Drawable dwpay_getall = getResources().getDrawable(R.drawable.incomeget);
        dwpay_getall.setBounds(0, 0, 100, 100);
        pay_getall.setCompoundDrawables(dwpay_getall, null, null, null);
        pay_getall.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        pay_getall.getPaint().setAntiAlias(true);//抗锯齿

        Drawable dwpay_exit = getResources().getDrawable(R.drawable.tuichu);
        dwpay_exit.setBounds(0, 0, 100, 100);
        pay_exit.setCompoundDrawables(dwpay_exit, null, null, null);
        pay_exit.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        pay_exit.getPaint().setAntiAlias(true);//抗锯齿


        setTitle("支出项目管理");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.pay_add:
                Toast.makeText(this,"进入支出项目增加功能",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, PayAddActivity.class));
                break;
            case R.id.pay_update:
                Toast.makeText(this,"进入支出项目修改功能",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, PayUpdateActivity.class));
                break;
            case R.id.pay_del:
                Toast.makeText(this,"进入支出项目删除功能",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, PayDelActivity.class));
                break;
            case R.id.pay_getall:
                Toast.makeText(this,"进入支出项目查询功能",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, PayGetAllActivity.class));
                break;
            case R.id.pay_exit:
                Toast.makeText(this,"返回上一级",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, MainActivity.class));
                break;
        }
    }
}
